package com.yulinlin.lang.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

public class SpringUtil  implements BeanFactoryAware {

    private static BeanFactory beanFactory;

    public static <E> E getBean(Class<E> clazz){
        return beanFactory.getBean(clazz);
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        SpringUtil.beanFactory = beanFactory;
    }
}
